using System;
using System.Collections.Generic;
using System.Text;
using KbWorksBlogMigrationtool.wss2007;
using System.Net;
using System.Xml;
using System.Data;
using System.Configuration;
namespace KbWorksBlogMigrationtool
{
    class ListsProxy2007
    {
        AppSettingsReader conf = new AppSettingsReader();
        private string url = string.Empty;
        private string listName = string.Empty;
        Logging log = new Logging();
        public ListsProxy2007(string Url)
        {
            if (Url == String.Empty)
            {
                throw new ArgumentException("Parameter may not be String.Empty", "Url");
            }
            url = Url + "/_vti_bin/Lists.asmx";
        }

        public ListsProxy2007(string Url, string ListName)
        {
            if (Url == String.Empty)
            {
                throw new ArgumentException("Parameter may not be String.Empty", "Url");
            }

            url = Url + "/_vti_bin/Lists.asmx";
            listName = ListName;
        }

        public XmlNode GetLists()
        {
            //Create a reference to the web service and set some properties
            KbWorksBlogMigrationtool.wss2007.Lists Lists = new KbWorksBlogMigrationtool.wss2007.Lists();
            Lists.Url = url;
            Lists.Credentials =
                new NetworkCredential(Convert.ToString(conf.GetValue("networkuser", typeof(string))),
                 Convert.ToString(conf.GetValue("networkpass", typeof(string))),
                 Convert.ToString(conf.GetValue("domain", typeof(string))));

            //Get the data from the list
            XmlNode listCollection = null;
            try
            {
                listCollection = Lists.GetListCollection();
            }
            catch ( Exception ex )
            {
                log.append("Unable to get Listcollection  on " + url + " " + ex.ToString(), 4, "Error");
            }
            finally
            {
                Lists.Dispose();
            }
            return listCollection;

        }
   
    }
}
